<?php
// 设置脚本类型
header('content-type:application/json;charset=UTF-8');

$connect = mysqli_connect('127.0.0.1', 'root', 'root', '22php');
$sql = "SELECT 
    `jan` AS January_Salary,
    `feb` AS February_Salary,
    `mar` AS March_Salary,
    `apr` AS April_Salary,
    `may` AS May_Salary,
    `jun` AS June_Salary,
    `jul` AS July_Salary,
    `aug` AS August_Salary,
    `sep` AS September_Salary,
    `oct` AS October_Salary,
    `nov` AS November_Salary,
    `dec` AS December_Salary
FROM `member_salary`
WHERE `member_id` = 3 AND `year` = '2024'";
$query = mysqli_query($connect, $sql);
$data = mysqli_fetch_all($query);
// print_r($data);
// echo json_encode(['code' => 1, 'msg' => 'success', 'data' => $data]);

//$month = [];
$yData = [];

foreach ($data as $value) {
    //$month[] = $value['0'];
    array_push($yData, $value);
}
// print_r(json_encode($yData));
echo json_encode(['code' => 1, 'msg' => '查询成功', 'data' => [
        //'month' => $month,
        'salary' => $yData
    ]
]);
